<?php


namespace app\controller;


use app\repository\Device\Room\RoomDeviceRepository;
use app\repository\Repository;
use support\Request;

class RoomDeviceController extends BaseController
{

    protected $repository;


    public function __construct(RoomDeviceRepository $repository)
    {
        $this->repository = $repository;
    }


    public function ready(Request $request)
    {
        $username = $request->input("username");
        if(!$username){
            return $this->error("系统出错误，参数缺失，请联系管理员");
        }
        $ready = $this->repository->ready($username);
        return $this->res($ready);
    }

    public function init_user(Request $request)
    {
        $username = $request->input("username");
        $ip = $request->input("ip");
        if (!$ip){
            return $this->error("获取局域网 ip 失败");
        }
        $init_user = $this->repository->init_user($username, $ip);
        return $this->res($init_user);
    }

}